DCN Review
[[01-Basic Concepts|01-Basic Concepts]]
Five components of data communication
- Protocol
- Sender
- Message
- Medium
- Receiver
Data flow
- Simplex
- Half-duplex
- Full-duplex
Capacity of Communication Channel
Nyquist's Theorem
- Assumption: noise free in the channel
- Formula:
- B = Bit Rate (bit/sec)
- F = Channel Bandwidth in Hertz
- M = Number of levels in a signal (two for binary)
Shannon's Theorem
- In reality, the signal may be corrupted by electrical noise.
- Formula:
- B = Actual Bit Rate (bit/sec)
- F = Channel Bandwidth in Hertz
- S = Signal Power in watts
- N = Noise Power in watts
Signal-to-Noise Ratio
The signal-to-noise ratio is often given in decibels.
Assume that
= 36 and the channel bandwidth is 2 MHz.
Open System Interconnection (OSI) Model
Physical Layer:
- It is concerned with transmitting raw bits over a communication channel.
- This layer deals with the issues including mechanical, electrical, timing interfaces, and the physical transmission medium.
Data Link Layer:
- It is to transform a raw transmission facility into a line that appears free of undetected transmission errors to the network layer.
Network Layer:
- It controls the operation of the subnet.
- It routes packets from source to destination.
- The routing algorithm can be static or dynamic.
Transport Layer:
- It is to accept data from upper layers.
- Split it up into smaller units if need be, pass these to the network layer,
- Ensure that the pieces all arrive correctly at the other hand.
Session Layer:
- It allows users on different machines to establish sessions between them.
Presentation Layer:
- It is concerned with the syntax and semantics of the information transmitted.
Application Layer:
- It contains a variety of protocols that are commonly needed by users.
- Such as HTTP, Email, etc.
- It contains a variety of protocols that are commonly needed by users.
[[02-Physical Layer|02-Physical Layer]]
Physical Layer:
- It is concerned with transmitting raw bits over a communication channel.
- This layer deals with the issues including mechanical, electrical, timing interfaces, and the physical transmission medium.
Guide Transmission Media
Guided media, which are those that provide a conduit from one device to another.
- Guide
wired
- Twisted-pair cable
- Coaxial cable
- Fiber-optic
Optical Fiber Propagation modes
- Mode
- Multimode
- Step index
- Graded index
- Single mode
- Multimode
Unguided Transmission Media
Unguided media transport electromagnetic waves without using a physical conductor.
- Unguided
wireless
- Free space
Two common signal encoding methods:
- Frequency hopping spread spectrum (e.g., Bluetooth)
- Direct sequence spread spectrum (e.g.,CDMA mobile network)
The Electromagnetic Spectrum
- Propagation Methods
- Ground Propagation
- Sky Propagation
- Line-of-sight Propagation
[[03-Data Link Layer|03-Data Link Layer]]
Data Link Layer:
- It is to transform a raw transmission facility into a line that appears free of undetected transmission errors to the network layer.
Framing techniques
- Character Count
- Flag bytes with byte stuffing
- Starting and ending flags with bit stuffing
Error Control
Error Detection
- Parity Check
- Two-dimensional Parity Check
- Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check
Error Correction forward error correction (FEC)
- Hamming Distance
- Hamming Code
Compare the features between Error Control and Error Correction methods
Error detection:
- To send additional information, so incorrect data can be detected and rejected.
Error correction:
- To send additional information, so incorrect data can be corrected and accepted.
- Error correction is the additional ability to reconstruct the original data.
- To send additional information, so incorrect data can be corrected and accepted.
Flow Control
- Stop-and-Wait Protocols
- Sliding Window Protocols
Multiple-access Protocols
- Channelization:
- Frequency-Division Multiple Access (FDMA)
- Time-Division Multiple Access (TDMA)
- Code-Division Multiple Access (CDMA)
- Random Access Protocols:
- Aloha
- Carrier Sense Multiple Access
- CSMA with Collision Detection
- CSMA with Collision Avoidance
- Controlled-Access Protocols: Collision-Free Protocol
- Reservation
- Polling
- Token passing
[[04-Network Layer|04-Network Layer]]
Network Layer:
- It controls the operation of the subnet.
- It routes packets from source to destination.
- The routing algorithm can be static or dynamic.
Internet Protocol
- IP is a protocol which
governs the data format of packets
sent over the Internet. - The main functions provided by IP are addressing and network routing.
Differences between IPv4 and IPv6
IPv4 | IPv6 | |
---|---|---|
IP address | 32 bit | 128 bit |
Address Notation | Numeric dot-decimal notation | Hexadecimal notation |
Header size | 20 bytes + optional | 40 bytes |
Checksum | Yes | No |
Major fields in IPv4 header
- Version
- Type of service
- Total length
- Time to live
- Source address, destination address
Major fields in IPv6 header
- Version
- Traffic class
- Flow label
- Payload length
- Next header
- Hop limit
Use NAT to increase IPV4 address
Transition from IPv4 to IPv6
- Dual stack
- Tunneling
- Header translation
Network Routing
Network routing selects a path over an internetwork to transmit one or more packets from the source to the destination.
Flooding Algorithm
Dijkstra Algorithm
Distance Vector Routing Algorithm
[[05-Transport Layer|05-Transport Layer]]
TCP
Transport Control Protocol (TCP)
- Source port and destination port: to identify the local end points of the connections.
- Sequence number and acknowledgement number
- TCP header length: to tell how many 32-bit words are contained in the header
- Six 1-bit flags
- Window size: to tell how many bytes may be sent starting at the byte acknowledged.
- Checksum
- Options: to provide a way to extend the header
UDP
User Datagram Protocol (UDP)
- Connectionless protocol
- Provide a way for applications to send encapsulated IP datagrams and send them without having to establish a connection.
- 8-byte header
- UDP Datagram Header
[[06-Application Layer|Application Lyer]]
API
- API stands for application programming interface.
- Socket API is specifically designed for the network programming interface.
Socket
Socket is an abstraction through which an application may send and receive data.
- A socket is uniquely identified together by
- Internet address
- End-to-end protocol (e.g. TCP or UDP)
- Port number
Stream sockets and Datagram sockets
- Stream socket is designed for TCP, which provides reliable byte stream service.
- Datagram socket is specifically designed for UDP, which provides best-effort datagram service.
Function Call
Basic function calls on the client side
WSAStartup
socket
connect
(send, recv) (recusive)
closesocket
WSACleanup
Basic function calls on the server side
WSAStartup
socket
bind
listen
accept
(recv, send) (recursive)
closesocket (pair up with accept)
WASCleanup
.
Basic Code segment
Create socket
int socket_desc=socket(AF_INET,SOCK_STREAM,0);
if (socket_desc==-1) perror("Create socket");
Binding a socket to a port
struct sockaddr_in address;
/* type of socket created in socket() */
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY; /* 7000 is the port to use for connections */
address.sin_port = htons(7000); /* bind the socket to the port specified above */
bind(socket_desc,(struct sockaddr *)&address,sizeof(address));
Listening for connections
listen(socket_desc,3);
Accepting a connection
int addrlen;
struct sockaddr_in address;
addrlen = sizeof(struct sockaddr_in);
new_socket = accept(socket_desc, (struct sockaddr *)&address, &addrlen); if (new_socket<0) perror("Accept connection");
Sending data to a connection
char *message="This is a message to send\n\r";
send(socket_desc, message, strlen(message), 0);
Receiving data from a connection
int bufsize=1024; /* a 1K buffer */
char *buffer=malloc(bufsize);
recv(socket_desc,buffer,bufsize,0);
Close
closesocket(msg_sock);
// close(socket_desc);
WSACleanup();
[[Multithreads]]
#include <process.h>
for(int i = 0; i < 100; i++){
_beginthread(accept_conn, 0, NULL );
}//for loop
_endthread();
// create a function to accept a connection
void accept_conn(void *dummy) {
// doing something here
}
[[07-Standardized Networks|07-Standardized Networks]]
Ethernet
- Standard Ethernet
10 Mbps
- Fast Ethernet
100 Mbps
- Gigabit Ethernet
1 Gbps
- Ten Gigabit Ethernet
10 Gbps
Determination of the Minimum Frame Standardized
Data transmission time
= Cable length
(线缆长度)= Propagation speed
(传播速度)= Bit rate
(比特率,单位为比特/秒)= Minimum data size
(最小数据大小)
Hub, Bridge, Router, and Switch
Hub 集线器
Hub is a repeater with some additional network management functionality (such as performance or accounting management)
Work on [[02-Physical Layer|02-Physical Layer]]
- 定义:Hub是一种网络设备,用于将多个以太网设备连接在一起,使它们能够作为一个网络段进行通信。
- 工作层次:物理层(OSI模型第1层)。
- 工作原理:Hub通过广播的方式将收到的数据包发送到所有连接的端口,无论数据包的目的地是哪个设备。
- 优点:价格低廉,易于安装和使用。
- 缺点:效率低,所有端口共享带宽,容易发生碰撞(Collision),不适合大规模网络。
Bridge 桥接器
Bridge: bridge operates on Ethernet frames and thus a layer-2 device. It does the following two functions:
- Filtering: determine whether a frame should be forwarded to some interface or should just be dropped.
- Forwarding: determine the interfaces to which a frame should be directed.
Work on [[03-Data Link Layer|03-Data Link Layer]]
- 定义:Bridge是一种网络设备,用于连接两个或多个网络段,主要用于分割网络冲突域。
- 工作层次:数据链路层(OSI模型第2层)。
- 工作原理:Bridge根据MAC地址表转发数据帧,只将数据帧发送到目的地所在的网络段,减少不必要的流量。
- 优点:减少网络冲突,提升网络效率。
- 缺点:管理复杂度高,不支持多播和广播控制。
Router 路由器
- Router: router is a store-and-forward packet switch that forward packets using network-layer addresses (layer-3).
- Although a bridge is also a store- and-forward packet switch, it forwards packets using LAN addresses.
- As a network administrator, how to choose between bridge and router?
Work on [[04-Network Layer|04-Network Layer]]
- 定义:Router是一种网络设备,用于连接不同的网络,能够根据IP地址进行数据包转发。
- 工作层次:网络层(OSI模型第3层)。
- 工作原理:Router根据路由表和IP地址选择最佳路径,将数据包转发到目的地网络。
- 优点:能够连接不同类型的网络,支持复杂的路由选择协议,提供广域网(WAN)连接。
- 缺点:成本较高,配置和管理相对复杂。
Switch 交换机
Switch: switch is in essence a high-performance multi-interface bridge. The difference between a bridge and switch:
Bridges usually two or four interfaces, whereas switches have dozens of interfaces (e.g., 24 ports).
Switches are usually used to connect individual computers, and operate in a full-duplex mode.